<?php
namespace app\admin\controller\soft;
use app\providers\BaseController;
use app\admin\model\SystemGroup;
use hg\apidoc\annotation as Apidoc;

/**
 * @Apidoc\Title("角色管理")
 * @Apidoc\Group("base")
 * @Apidoc\Sort(1)
 */
class Group extends BaseController
{
    /**
     * 排序调整
     * @Apidoc\Desc("排序调整")
     * @Apidoc\Author("weifashi")
     * @Apidoc\Url("admin/soft/group/sortMove")
     * @Apidoc\Method("POST")
     * @Apidoc\Param("moveId",type="int",require=true,default="1",desc="id1" )
     * @Apidoc\Param("coverId", type="int",require=true, default="2",desc="id2" )
     */
	public function sortMove($moveId,$coverId){
		if( empty($moveId) )
			throw new \think\Exception('moveId参数不能为空');
		if( empty($coverId) )
			throw new \think\Exception('coverId参数不能为空');
		
		if($moveId==-1 || $coverId==-1){
			return \Api::ReSucess("","操作成功");
		} 
		
		$result = (new SystemGroup)->updateSort($moveId,$coverId);
		if($result){
			return \Api::ReSucess("","操作成功");
		}else{
			return \Api::ReError("未知错误！");
		}
		
	}
	
	/**
     * 获取权限
     * @Apidoc\Desc("获取当前分组权限")
     * @Apidoc\Author("weifashi")
     * @Apidoc\Url("admin/soft/group/getAction")
     * @Apidoc\Method("POST")
     * @Apidoc\Param("org_id",type="int",require=true,default="",desc="组织id" )
     */
	public function getAction($org_id){
		$result = SystemGroup::where('org_id',$org_id)->value('action');
		return \Api::ReSucess($result,"操作成功");
	}
	
}
